package com.example.day07;

public class BookInfo {

    private   int id;
    private  String author;


    public BookInfo() {
    }

    public BookInfo(int id, String author) {
        this.id = id;
        this.author = author;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    @Override
    public int hashCode() {
        return  id;
    }

//    @Override
//    public boolean equals(Object obj) {
//        if(obj==null){
//            return  false;
//        }
//        if(this==obj)
//            return  true;
//        if(obj instanceof  BookInfo){
//            BookInfo b= (BookInfo) obj;
//            return  id==b.id;
//
//        }
//        return false;
//    }


    @Override
    public boolean equals(Object obj) {
        if(this==obj) return  true;
        if(obj==null || getClass()!=obj.getClass()) return  false;

        BookInfo bookInfo= (BookInfo) obj;
        return  id== bookInfo.id;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("BookInfo{");
        sb.append("id=").append(id);
        sb.append(", author='").append(author).append('\'');
        sb.append('}');
        return sb.toString();
    }
}
